/**
 * 请求成功
 */
export const CODE_SUCCESS = 0;

/**
 * 请求失败
 */
export const CODE_FAIL = 1;

export interface ResType {
  code: number;
  message: string;
  data: any;
}

const render = (res: ResType) => {
  return JSON.stringify(res);
};

export const resSuccess = (data?: any) => {
  return render({ code: CODE_SUCCESS, message: 'success', data });
};

export const resFail = (msg: string, data?: any) => {
  return render({ code: CODE_FAIL, message: msg, data });
};
